package com.xcode.xandrdb;

import java.util.List;

import com.xcode.xandrdb.Factory.SessionConfig;
import com.xcode.xandrdb.Factory.SessionFactory;
import com.xcode.xandrdb.interfaces.Session;
import com.xcode.xandrdb.mapper.test;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class MainActivity extends Activity
{
	test t1 = null;
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Session session = SessionFactory.getSession(new SessionConfig().setDBName("xiaolei"));
		t1 = session.getMapper(test.class);
		t1.create("xiaolei");
		long startTime = System.currentTimeMillis();
		for (int i = 0; i < 50; i++)
		{
			t1.insert();
		}
		
		session.commit();
		
		long  endTime = (System.currentTimeMillis() - startTime);
		
		Toast.makeText(this, ""+endTime, Toast.LENGTH_LONG).show();;
		
		List<User> list = t1.select("xiaolei");
		System.out.println(list.size());
		list = t1.select("xiaolei");
		System.out.println(list.size());
		list = t1.select("xiaolei");
		System.out.println(list.size());
		try
		{
			Thread.sleep(2000);
			list = t1.select("xiaolei");
			System.out.println(list.size());
		} catch (InterruptedException e)
		{
			e.printStackTrace();
		}
		
	}
}
